package test;

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class MannageService extends JFrame {
    public MannageService() {
        this.setTitle("智慧社区服务平台");
        this.setSize(600, 400);
        this.setDefaultCloseOperation(2);
        this.setLocationRelativeTo((Component)null);
        JPanel topPanel = new JPanel();
        topPanel.setLayout(new GridLayout(1, 4));
        JButton paymentButton = new JButton("缴费");
        JButton repairButton = new JButton("报修");
        JButton policyButton = new JButton("政策");
        JButton governmentButton = new JButton("政务");
        Font buttonFont = new Font("SimSun", 1, 16);
        paymentButton.setFont(buttonFont);
        repairButton.setFont(buttonFont);
        policyButton.setFont(buttonFont);
        governmentButton.setFont(buttonFont);
        paymentButton.addActionListener((e) -> {
            PAY.main((String[])null);
            this.dispose();
        });
        repairButton.addActionListener((e) -> {
            RepairService.main((String[])null);
            this.dispose();
        });
        policyButton.addActionListener((e) -> {
            PolicyService.main((String[])null);
            this.dispose();
        });
        governmentButton.addActionListener((e) -> {
            PolicyWebsiteService.main((String[])null);
            this.dispose();
        });
        topPanel.add(paymentButton);
        topPanel.add(repairButton);
        topPanel.add(policyButton);
        topPanel.add(governmentButton);
        this.add(topPanel, "North");
        JPanel bottomPanel = new JPanel();
        bottomPanel.setLayout(new FlowLayout(2));
        JButton returnButton = new JButton("返回");
        String loggedInUsername = null;
        returnButton.addActionListener((e) -> {
            Menu menu = new Menu(loggedInUsername);
            menu.setVisible(true);
            this.dispose();
        });
        bottomPanel.add(returnButton);
        this.add(bottomPanel, "South");
        this.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowEvent) {
                Menu menu = new Menu(loggedInUsername);
                menu.setVisible(true);
            }
        });
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            MannageService manageService = new MannageService();
            manageService.setVisible(true);
        });
    }
}